<template>
	<view class="index" :class="uiStyle == 1 ? '' : 'uiStyle'">
		<!-- <topBar text="邻里停"></topBar> -->
		<view class="my-page">
			<view class="user-title login" v-if="isLogin">
				<img style="width: 100%" src="../../static/assets/img/bg.png" mode="widthFix"></img>
				<view class="user-title-right">
					<view class="user1" v-if="username">欢迎，</view>
					<view class="user2" v-if="username">{{ username }}</view>
				</view>
				<view :class="isqd ? 'setting-qd-comm setting-complete-complete-qd' : 'setting-qd-comm setting-qd'">
					<img class="qd-icon" src="../../static/assets/img/qd.png"></img>
					<view v-if="isqd" class="qd-box">
						<view class="tody-qd" style="">已打卡</view>
						<!-- <view class="tody-jf" style="font-size: 40rpx;color:#FFFFFF">+10积分</view> -->
					</view>
					<view v-else class="qd-box" @tap="handSign">
						<view class="tody-qd" style="">今日打卡</view>
						<!-- <view class="tody-jf" style="font-size: 40rpx;color:#FFFFFF">+10积分</view> -->
					</view>
				</view>

				<view class="top-right-tip">
					<view class="weather">
						<img :src="weather.icon" style="width: 64rpx;display: inline-block;" mode="widthFix"></img>
						{{ weather.weather || '' }}
					</view>
					<!-- {{weather.temperature || ''}}℃ -->
					<!-- <view class="city-local" wx:if="{{weather.city}}">
      <img src="/assets/img/dingwei.png"></img>{{weather.city||'定位中'}}
    </view> -->
					<view class="control-box" v-if="controlNo">今日限行 {{ controlNo }}</view>
					<view class="control-box" v-else>今日不限行</view>
				</view>
			</view>
			<view class="user-title" v-else @tap="gotoLogin">
				<img src="../../static/assets/img/bg.png" style="" mode="widthFix" />
				<view class="user-title-right">
					<view class="user1">欢迎，</view>
					<view class="user2">游客</view>
					<view class="user2">点击登录</view>
				</view>
				<view class="top-right-tip">
					<view class="weather" v-if="weather.weather">
						<img :src="weather.icon" style="width: 64rpx" mode="widthFix"></img>
						{{ weather.weather || '获取中' }}
					</view>
					<!-- {{weather.temperature || ''}}℃ -->
					<!-- <view class="city-local" wx:if="{{weather.city}}">
      <img src="/assets/img/dingwei.png"></img>{{weather.city||'定位中'}}
    </view> -->
					<view class="control-box" v-if="controlNo">今日限行 {{ controlNo }}</view>
					<view class="control-box" v-else>今日不限行</view>
				</view>
			</view>

			<view class="block-content1">
				<view class="left" @tap="goIndex">
					<img style="position: absolute; width: 100%" src="../../static/assets/img/parking.png"
						mode="widthFix"></img>
					<view class="title1">
						我要停车
						<view class="parkInfo">
							<view class="parkInfo1" style="margin-bottom: 15rpx">
								附近停车场
								<text
									style="font-family: DIN-Bold; font-size: 42rpx; color: #00baa8; font-weight: 700">{{ parkInfo.total }}</text>
							</view>
							<view class="parkInfo2">
								其中可充电
								<text
									style="font-family: DIN-Bold; font-size: 42rpx; color: #00baa8; letter-spacing: 0; line-height: 44rpx; font-weight: 700">
									{{ parkInfo.charge }}
								</text>
							</view>
						</view>
					</view>
				</view>
				<view class="right">
					<view class="right1" @tap="goMarket">
						<img style="position: absolute; width: 100%" src="../../static/assets/img/goMarket.png"
							mode="widthFix"></img>
						<view class="title1" style="">
							快捷预约
							<view class="market">
								<view class="market1" style="width: 300rpx">
									<text
										style="font-family: DIN-Bold; font-size: 36rpx; color: #2589ff; font-weight: 700">
										{{ parkInfo.order }}
										<text
											style="font-size: 26rpx; color: #2589ff; letter-spacing: 0; font-weight: 400; font-family: PingFangSC-Regular">车位</text>
									</text>
								</view>
								<view class="market2"
									style="font-family: PingFangSC-Regular; font-size: 26rpx; color: #999999; letter-spacing: 0; font-weight: 400; height: 40rpx">
									可预约
								</view>
								<view class="market2"
									style="font-family: PingFangSC-Regular; font-size: 26rpx; color: #999999; letter-spacing: 0; font-weight: 400">
									长租/临停
								</view>
							</view>
						</view>
					</view>

					<view class="right2" @tap="goBill" style="position: relative; top: 40rpx">
						<img style="position: absolute; width: 100%" src="../../static/assets/img/goBill.png"
							mode="widthFix"></img>
						<view class="title1" style="">
							我的订单
							<text
								style="font-family: PingFangSC-Regular; font-size: 26rpx; color: #999999; letter-spacing: 0; font-weight: 400">预约记录</text>
						</view>
					</view>
				</view>
			</view>
			<view class="block-content2">
				<view class="block-content21" @tap="goPublic" style="width: 50%; margin-right: 10rpx">
					<img style="width: 100%" src="../../static/assets/img/goPublic.png" mode="widthFix"></img>
					<view class="title2" style="">
						我要发布车位
						<view class="look"
							style="display: block; font-family: PingFangSC-Regular; font-size: 26rpx; color: #999999; letter-spacing: 0; font-weight: 400">
							闲置时段赚钱</view>
					</view>
				</view>
				<view class="block-content22" @tap="goLlgx" style="width: 50%; margin-left: 10rpx">
					<img style="width: 100%" src="../../static/assets/img/llcw.png" mode="widthFix"></img>
					<view class="title2" style="">
						邻里车位
						<view class="look"
							style="display: block; font-family: PingFangSC-Regular; font-size: 26rpx; color: #999999; letter-spacing: 0; font-weight: 400">
							查看本小区车位</view>
					</view>
				</view>
			</view>
			<view class="block-content3" style="display: flex;">
				<swiper style="width: 100%;;" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
					:duration="duration">
					<block style="width: 100%;" class="block-content31" v-for="(item, index) in imgUrls" :key="index">
						<swiper-item style="width: 100%;">
							<image @tap="goPoint" :src="item" class="slide-image" style="width: 100%; " webp="true"
								mode="widthFix"></image>
						</swiper-item>
					</block>
				</swiper>
			</view>
			<view class="bot_mark" v-if="weixin == 3 || weixin == 4">
				本服务由浙江政务服务网、杭州市滨江区浦沿街道提供<br>
				服务热线:<text @tap="payPhone('0571-96371')">0571-96371</text>
			</view>
			<view style="height: 80rpx;" v-if="weixin == 3 || weixin == 4">

			</view>
		</view>
	</view>
</template>

<script>
	import util from './../../utils/util.js';
	import api from './../../utils/api.js';
	import topBar from './../../pages/components/topBar/index.vue';
	import amapFile from './../../utils/amap-wx.js';
	export default {
		data() {
			return {
				imgUrls: [],
				current: 0,

				//当前所在页面的 index
				indicatorDots: true,

				//是否显示面板指示点
				autoplay: true,

				//是否自动切换
				interval: 3000,

				//自动切换时间间隔
				duration: 800,

				//滑动动画时长
				circular: true,

				//是否采用衔接滑动
				parkInfo: {
					total: '',
					charge: ''
				},

				isLogin: false,
				username: '',
				phoneNumber: '',
				plateNos: '',
				isqd: false,

				//是否签到
				weather: {
					weather: '',
					icon: ''
				},

				//天气信息
				iconWeatherMap: {
					风: ['有风', '平静', '微风', '和风', '清风', '强风/劲风', '疾风', '大风', '烈风', '风暴', '狂爆风', '飓风', '热带风暴', '龙卷风'],
					多云: ['少云', '晴间多云', '多云'],
					雪: ['雪', '阵雪', '小雪', '中雪', '大雪', '暴雪', '小雪-中雪', '中雪-大雪', '大雪-暴雪', '冷'],
					雾: ['浮尘', '扬沙', '沙尘暴', '强沙尘暴', '雾', '浓雾', '强浓雾', '轻雾', '大雾', '特强浓雾'],
					晴: ['晴', '热'],
					雨夹雪: ['雨雪天气', '雨夹雪', '阵雨夹雪'],
					雨: [
						'阵雨',
						'雷阵雨',
						'雷阵雨并伴有冰雹',
						'小雨',
						'中雨',
						'大雨',
						'暴雨',
						'大暴雨',
						'特大暴雨',
						'强阵雨',
						'强雷阵雨',
						'极端降雨',
						'毛毛雨/细雨',
						'雨',
						'小雨-中雨',
						'中雨-大雨',
						'大雨-暴雨',
						'暴雨-大暴雨',
						'大暴雨-特大暴雨',
						'冻雨'
					],
					阴: ['阴', '霾', '中度霾', '重度霾', '严重霾', '未知']
				},

				faceImageUrl: '',
				controlNo: '',
				uiStyle: 1,
				weixin: 0
			};
		}
		/**
		 * 生命周期函数--监听页面加载
		 */
		,
		onLoad: function(options) {
			var that = this;
			var ua = navigator.userAgent.toLowerCase();
			localStorage.setItem('uiStyle', 1)
			if (ua.match(/MicroMessenger/i) == "micromessenger") {
				//ios的ua中无miniProgram，但都有MicroMessenger（表示是微信浏览器）
				const wexin = jWeixin
				wexin.miniProgram.getEnv((res) => {
					if (res.miniprogram) {
						localStorage.setItem('weixin', 2)
					} else {
						localStorage.setItem('weixin', -1)
						// this.onloads(options)
					}
				})
				// localStorage.setItem('weixin', 2)
				uni.removeStorageSync('projectId')
			} else {
				ZWJSBridge.onReady(() => {
					// console.log('初始化完成后，执行bridge方法')
				})
				ZWJSBridge.getUiStyle({})
					.then((result) => {
						switch (result.uiStyle) {
							case 'normal':
								localStorage.setItem('uiStyle', 1)
								setUiStyle('标准模式');
								break;
							case 'elder':
								localStorage.setItem('uiStyle', 2)
								setUiStyle('适老模式');
								break;
							default:
								setUiStyle('default');
						}
					}).catch((error) => {
						setUiStyle('catch 标准模式兼容');
					});
				const bIsDtDreamApp = ua.indexOf("dtdreamweb") > -1; // 浙里办APP
				const bIsAlipayMini =
					ua.indexOf("miniprogram") > -1 &&
					ua.indexOf("alipay") > -1;
				// 浙里办支付宝小程序
				if (bIsDtDreamApp) {
					localStorage.setItem('weixin', 3)
					//浙里办app
				} else if (bIsAlipayMini) {
					localStorage.setItem('weixin', 4) //支付宝浙里办app
				} else {
					localStorage.setItem('weixin', -1) //h5浏览器
				}
			}

			// 微信小程序授权code
			if (uni.getStorageSync('weixin') == 2 && options.code) {
				let {
					code,
					encryptedData,
					iv,
					nikeName,
					gotoLLT
				} = options
				uni.showLoading({
					title: '加载中'
				});
				let param = {
					code
				};
				util.request(api.wxLogin, param, 'POST')
					.then((res) => {
						if (res.success) {
							//有openid直接进首页前也要判断有无车牌
							uni.hideLoading();
							uni.setStorage({
								key: 'AUTHORIZATION',
								data: res.data.busiInfo.token
							}); //token

							this.setStorages(res); //开始存储所需要的信息
							if (gotoLLT) {
								let phoneData = {
									phone: res.data.busiInfo.phoneNumber
								}
								util.request(api.newSeeCustSpaceInit, phoneData, 'GET')
									.then((result) => {
										if (result.success) {
											uni.hideLoading();

										} else {
											uni.hideLoading();
											uni.showToast({
												title: result.msg || '接口出错了，请重试',
												icon: 'none'
											});
											let that = this;
										}
									})
							}
						} else {
							//无openid去绑定,有车牌直接进首页，无则进修改页---没有车牌也暂时跳过去首页
							uni.setStorage({
								key: 'AUTHORIZATION',
								data: res.data.busiInfo.token
							});
							uni.setStorage({
								key: 'openId',
								data: res.data.busiInfo.openId
							}); //openId

							const wechatUnionId = res.wechatUnionId;
							let param = {
								nikeName: '用户_' + nikeName,
								openId: res.data.busiInfo.openId,
								url: '',
								encryptedData: encryptedData + "==",
								iv: iv + "==",
								wechatUnionId: wechatUnionId
							}; // 如果从分享进来注册的，还需要加上分享人的参数
							if (uni.getStorageSync('shareId')) {
								param.originUnionId = uni.getStorageSync('shareId') || '';
							}

							if (uni.getStorageSync('activityCode')) {
								param.activityCode = uni.getStorageSync('activityCode') || '';
							}
							util.request(api.wxBind, param, 'POST')
								.then((resp) => {
									if (resp.success) {
										uni.hideLoading();
										uni.removeStorageSync('shareId'); //移除掉分享者id缓存

										uni.setStorage({
											key: 'AUTHORIZATION',
											data: resp.data.busiInfo.token
										}); //token

										this.setStorages(resp);
										if (gotoLLT) {
											let phoneData = {
												phone: resp.data.busiInfo.phoneNumber
											}
											util.request(api.newSeeCustSpaceInit, phoneData, 'GET')
												.then((result) => {
													if (result.success) {
														uni.hideLoading();

													} else {
														uni.hideLoading();
														uni.showToast({
															title: result.msg || '接口出错了，请重试',
															icon: 'none'
														});
														let that = this;
													}
												})
										}

									} else {
										uni.hideLoading();
										uni.showToast({
											title: resp.msg || '接口出错了，请重试',
											icon: 'none'
										});
										let that = this;
									}
								})
						}
						this.onloads(options)
					})
					.catch((err) => {
						uni.hideLoading();
						let that = this;
						// uni.showToast({
						// 	title: '接口出错了，请重试',
						// 	icon: 'none'
						// });
					});
			} else if (options.ticket) {
				util.request(api.zjLogin, {
						ssoTicket: options.ticket
					}, 'post', 'application/x-www-form-urlencoded')
					.then((res) => {
						if (res.success) {
							(function(w, d, s, q, i) {
								w[q] = w[q] || [];
								var f = d.getElementsByTagName(s)[0],
									j = d.createElement(s);
								j.async = true;
								j.id = 'beacon-aplus';
								j.src = 'https://d.alicdn.com/alilog/mlog/aplus.js?id=202951085';
								f.parentNode.insertBefore(j, f);
							})(window, document, 'script', 'aplus_queue');
							// 如采集用户信息是异步行为需要先执行这个 BLOCK 埋点
							aplus_queue.push({
								action: 'aplus.setMetaInfo',
								arguments: ['_hold', 'BLOCK']
							});
							// 设置会员昵称
							aplus_queue.push({
								action: "aplus.setMetaInfo",
								arguments: ["_user_nick", res.data.username]
							});
							// 设置会员 ID
							aplus_queue.push({
								action: "aplus.setMetaInfo",
								arguments: ["_user_id", res.data.governmentId]
							});
							aplus_queue.push({
								action: "aplus.sendPV",
								arguments: ["userType", 1]
							});
							// 如采集用户信息是异步行为，需要在设置完用户信息后执行这个 START 埋点	此时被 block 住的日志会携带上用户信息逐条发出
							aplus_queue.push({
								action: 'aplus.setMetaInfo',
								arguments: ['_hold', 'START']
							});
							this.goLogin(options, res.data.mobile)
						} else {
							this.onloads(options)
						}
					})
					.catch((err) => {
						console.log(err);
					});
			} else if (uni.getStorageSync('weixin') == 3 || uni.getStorageSync('weixin') == 4) {
				// 浙里办单点登录
				uni.navigateTo({
					url: '../indexk/indexk'
				})
			} else if (options.projectId && options.phone) {
				uni.setStorageSync('projectId', options.projectId)
				uni.showModal({
					title: '提示',
					content: "为了给业主提供更好的停车体验，“邻里停”将获取您的业主身份信息（小区名称、车位号)用于身份验证。",
					confirmColor: '#00bcab',
					confirmText: '授权',
					success: res => {
						if (res.confirm) {
							this.goLogin(options, options.phone)
						}
					}
				})
				
			} else {
				this.onloads(options)
			}
			if (uni.getStorageSync('weixin') == 3 || uni.getStorageSync('weixin') == 4) {
				this.getlocation() //埋点经纬度
			}
			this.uiStyle = uni.getStorageSync('uiStyle') || 1
			this.weixin = uni.getStorageSync('weixin')
		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		// onShareAppMessage: function () {
		// }
		onReachBottom: function() {},
		/**
		 * 用户点击右上角分享
		 */
		methods: {
			// 拨打电话
			payPhone(e) {
				if (uni.getStorageSync('weixin') == 3 || uni.getStorageSync('weixin') == 4) {
					ZWJSBridge.phoneCall({
						"corpId": e
					}).then(res => {
						console.log(res)
					}).catch(err => {
						console.log(err)
					})
				} else {
					uni.makePhoneCall({
						phoneNumber: e
					}).catch((e) => {
						console.log(e);
					});
				}
			},
			goLogin(options, phone) {
				let param = {
					loginName: phone
				};
				uni.showLoading({
					title: '加载中...'
				});
				util.request(api.noverifyLogin, param, 'POST', 'application/x-www-form-urlencoded')
					.then((result) => {
						uni.hideLoading({
							success: (res) => {}
						});
						if (result.success) {

							uni.setStorageSync("AUTHORIZATION", result.data.busiInfo.token);
							uni.setStorageSync("status", true); //状态
							uni.setStorageSync(
								"phoneNumber",
								result.data.busiInfo.phoneNumber,
								// 7 * 24 * 60 * 60 * 1000
							); //手机号
							uni.setStorageSync(
								"name",
								result.data.busiInfo.name,
								// 7 * 24 * 60 * 60 * 1000
							); //姓名
							uni.setStorageSync(
								"plateNos",
								result.data.busiInfo.plateNos != null && result.data.busiInfo.plateNos.length >
								0 && result.data.busiInfo.plateNos.map((e) => e).toString() || "",
								// 7 * 24 * 60 * 60 * 1000
							); //用户车牌号
							uni.setStorageSync(
								"faceImageUrl",
								result.data.busiInfo.faceImageUrl,
								// 7 * 24 * 60 * 60 * 1000
							); //头像
							uni.setStorageSync(
								"authorization",
								result.data.busiInfo.token,
								// 7 * 24 * 60 * 60 * 1000
							); //token
							// alert(Vue.ls.get("authorization"))
							uni.setStorageSync(
								"identityId",
								result.data.busiInfo.identityId,
								// 7 * 24 * 60 * 60 * 1000
							); //用户id
							uni.setStorageSync(
								"unionId",
								result.data.busiInfo.unionId,
								// 7 * 24 * 60 * 60 * 1000
							);
							this.onloads(options)
							if (options.projectId) {
								let phoneData = {
									phone: options.phone,
									projectHouseId: options.projectId
								}
								util.request(api.newSeeCustSpaceInit, phoneData, 'GET')
									.then((result) => {
										if (result.success) {
											uni.hideLoading();
											uni.setStorageSync('projectHouseId', options.projectId)
										} else {
											uni.hideLoading();
											uni.showToast({
												title: result.msg || '接口出错了，请重试',
												icon: 'none'
											});
											let that = this;
										}
									})
							}
						}
					})
					.catch((err) => {
						uni.showToast({
							title: err || '接口出错了，请稍后再试',
							icon: 'none'
						});
					});
			},
			// 获取经纬度
			getlocation() {
				ZWJSBridge.getLocation({})
					.then((res) => {
						// console.log('zwj获取经纬度', res)
						this.lat = res.latitude;
						this.lng = res.longitude;
						aplus_queue.push({
							action: "aplus.sendPV",
							arguments: ["long", res.longitude]
						});
						aplus_queue.push({
							action: "aplus.sendPV",
							arguments: ["lati", res.latitude]
						});
					}).catch((error) => {});
			},
			onloads(options) {
				const unionId = uni.getStorageSync('unionId');
				var that = this
				this.getTrafficControl();
				this.getPersonInfoByIndentityId(unionId);
				this.isWaitingToRead();
				this.getCurLocation(); // 处理关于分享的用户unionId

				if (options.shareId && options.shareId != '') {
					uni.setStorageSync('shareId', options.shareId);
				}

				if (options.activityCode && options.activityCode != '') {
					uni.setStorageSync('activityCode', options.activityCode);
				}
				setTimeout(function() {
					that.getWeather();
				}, 10000);
				util.request(api.bannerList + '?type=1', '', 'GET')
					.then((res) => {
						if (res.success) {
							console.log(res);
							this.imgUrls = res.data

						}
					})
					.catch((err) => {
						console.log(err);
					});
				if (uni.getStorageSync('AUTHORIZATION')) {
					this.setData({
						isLogin: true
					});
					const unionId = uni.getStorageSync(
						'unionId'); // this.getPersonInfoByIndentityId(unionId);//暂时不要从接口取头像 会导致每次都会加载闪一下

					this.setData({
						faceImageUrl: uni.getStorageSync('faceImageUrl')
					});
					this.todaySignStatus(unionId); // this.getmyInCome(unionId);
				} else {
					this.setData({
						isLogin: false
					});
				} // 存储当前页面-登陆后跳转至登录前页面					
				const page = getCurrentPages();
				// console.log('11111111111111111111111111111',page[0].route)
				uni.setStorageSync('lastPagePath', '/' + page[0].route);
			},
			/***缓存参数 */
			setStorages(res) {
				uni.setStorage({
					key: 'name',
					data: res.data.busiInfo.name
				}); //姓名

				uni.setStorage({
					key: 'phoneNumber',
					data: res.data.busiInfo.phoneNumber
				}); //手机号

				uni.setStorage({
					key: 'faceImageUrl',
					data: res.data.busiInfo.faceImageUrl
				}); //头像

				uni.setStorage({
					key: 'identityId',
					data: res.data.busiInfo.identityId
				}); //用户id

				uni.setStorage({
					key: 'unionId',
					data: res.data.busiInfo.unionId
				}); //用户id

				if (res.data.busiInfo.plateNos != null && res.data.busiInfo.plateNos.length > 0) {
					uni.setStorage({
						key: 'status',
						data: true
					}); //状态

					uni.setStorage({
						key: 'plateNos',
						data: res.data.busiInfo.plateNos.map((e) => e).toString()
					}); //用户车牌号
					// v2.5.4新加的访客链接进入时的逻辑

					if (uni.getStorageSync('visitor_code')) {
						uni.redirectTo({
							url: '../newBookpark/newBookpark?param=' + uni.getStorageSync('visitor_parkcode')
						});
					} else {
						uni.switchTab({
							url: uni.getStorageSync('lastPagePath') ? uni.getStorageSync('lastPagePath') :
								'../home/index'
						});
					}
				} else {
					uni.setStorage({
						key: 'status',
						data: true
					}); //状态

					uni.setStorage({
						key: 'plateNos',
						data: ''
					}); //用户车牌号
					// v2.5.4新加的访客链接进入时的逻辑

					if (uni.getStorageSync('visitor_code')) {
						uni.redirectTo({
							url: '../addLicense/addLicense'
						});
					} else {
						uni.switchTab({
							url: uni.getStorageSync('lastPagePath') ? uni.getStorageSync('lastPagePath') :
								'../home/index'
						});
					}
				}
			},
			setData: function(obj) {
				let that = this;
				let keys = [];
				let val, data;
				Object.keys(obj).forEach(function(key) {
					keys = key.split('.');
					val = obj[key];
					data = that.$data;
					keys.forEach(function(key2, index) {
						if (index + 1 == keys.length) {
							that.$set(data, key2, val);
						} else {
							if (!data[key2]) {
								that.$set(data, key2, {});
							}
						}
						data = data[key2];
					})
				});
			},
			/**
			 * 根据天气现象返回其图标icon url*/
			getIcon(weather) {
				// 这个是icon的默认值
				let url = 'static/assets/img/weather/阴.png';
				let index = 0;

				for (const weatherKey in this.iconWeatherMap) {
					if (Object.hasOwnProperty.call(this.iconWeatherMap, weatherKey)) {
						const weatherNames = this.iconWeatherMap[weatherKey];
						const findWeatherItem = weatherNames.find((name) => weather === name); // 如果找了某一类的图标了，那重新复制url

						if (findWeatherItem) {
							// 这里的weatherKey和icon的名字一一对应了
							url =
								`static/assets/img/weather/${index}.png`; // console.debug('@find weather key = ', weatherKey)

							break;
						}
					}

					index++;
				}

				return url;
			},

			//获取个人资料
			getPersonInfoByIndentityId(value) {
				if (!value) {
					return;
				}

				util.request(api.PersonInfoByIndentityId + '?personUnionId=' + value, 'get').then((res) => {
					if (res.code == 0) {
						var pat = /(\d{3})\d*(\d{4})/;
						this.setData({
							username: res.data.name ? res.data.name : '',
							phoneNumber: res.data.phoneNumber ? res.data.phoneNumber.replace(pat,
								'$1****$2') : '',
							plateNos: res.data.plateNos ? res.data.plateNos.map((e) => e.split(',')) : ''
						});
					} //头像转化

					if (res.data && res.data.headImageUrl) {
						util.request(api.getEncryPath + '?path=' + res.data.headImageUrl, '', 'POST').then((
							res) => {
							this.setData({
								faceImageUrl: res
							});
							uni.setStorageSync('faceImageUrl', res);
						});
					} else {
						this.setData({
							faceImageUrl: ''
						});
					} // 上传完成需要更新 fileList
				});
			},

			handSign() {
				//手动签到
				const unionId = uni.getStorageSync('unionId') || '';
				util.request(api.todaySign + '?unionId=' + unionId, 'get').then((res) => {
					if (res.code == 0) {
						uni.showToast({
							title: res.data,
							icon: 'none'
						});
						this.setData({
							isqd: true
						});
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				});
			},

			todaySignStatus(unionId) {
				//获取签到状态
				util.request(api.todaySignStatus + '?unionId=' + unionId, 'get').then((res) => {
					if (res.code == 0) {
						this.setData({
							isqd: res.data
						});
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				});
			},

			// 获取限牌
			getTrafficControl() {
				util.request(api.getTrafficControl, '', 'GET')
					.then((res) => {
						if (res.success) {
							this.setData({
								controlNo: res.data == null ? '' : res.data.join(' ')
							});
						}
					})
					.catch((err) => {
						console.log(err);
					});
			},

			goLlgx() {
				// 邻里共享
				uni.navigateTo({
					url: '../community1/index'
				});
			},

			isWaitingToRead() {
				//新消息留言
				const unionId = uni.getStorageSync('unionId');

				if (!unionId) {
					return;
				}

				util.request(
					api.isWaitingToRead, {
						unionId: unionId
					},
					'POST',
					'application/x-www-form-urlencoded'
				).then((res) => {
					console.log(res);

					if (res.data) {
						uni.showTabBarRedDot({
							index: 1
						});
					} else {
						uni.hideTabBarRedDot({
							index: 1
						});
					}
				});
			},

			// 使用高德提供的天气
			getWeather() {
				let that = this;
				var myAmapFun = new amapFile.AMapWX({
					key: 'a29210026b1d7fd7df6f765b2588c301'
				});
				myAmapFun.getWeather({
					success: function(data) {
						// console.log(data)
						data.liveData.icon = that.getIcon(data.weather.data);
						that.setData({
							weather: data.liveData
						});
						console.log(that.weather); //成功回调
					},
					fail: function(info) {
						//失败回调
						console.log(info);
					}
				});
			},

			// 跳转登录页
			gotoLogin() {
				if (uni.getStorageSync('weixin') == 2) {
					jWeixin.miniProgram.reLaunch({
						url: "/pages/login/login"
					})
				} else {
					if (uni.getStorageSync('weixin') == 3 || uni.getStorageSync('weixin') == 4) {
						uni.reLaunch({
							url: '/pages/indexk/indexk'
						})
					} else {
						uni.reLaunch({
							url: '/pages/login/index'
						});
					}
				}
				// uni.navigateTo({
				// 	url: '../login/index'
				// });
			},

			goIndex() {
				uni.navigateTo({
					url: '../index/index'
				});
			},

			goBill() {
				uni.navigateTo({
					url: '../order/index'
				});
			},

			goMarket() {
				uni.navigateTo({
					url: '../index2/index'
				});
			},

			goPublic() {
				const value = 2; //../communityOrder/index

				uni.navigateTo({
					url: '../communityOrder/index' //../setParking1/index?active     +=value
				});
			},

			/**
			 * 获取用户当前位置,获取后调用接口数据
			 *
			 */
			getCurLocation() {
				let that = this;
				console.log("getCurLocation")
				uni.getLocation({
					type: 'gcj02',
					success: (res) => {
						console.log(res);
						util.request(api.queryBase + '?mapx=' + res.longitude + '&mapy=' + res.latitude +
								'&distance=' + 1500, '', 'GET')
							.then((res) => {
								if (res.success) {
									// console.log(res)
									this.setData({
										parkInfo: res.data
									});
								}
							})
							.catch((err) => {
								console.log(err);
							});
					},

					fail(e) {
						console.log(e);
						uni.getSetting({
							success(result) {
								// 先获取用户是否已开启定位权限
								let setting = result.authSetting;
								let setLocation = 'scope.userLocation';

								if (!setting[setLocation]) {
									// 定位权限未开启，引导设置
									uni.showModal({
										title: '温馨提示',
										content: '您已拒绝定位,请开启',
										confirmText: '去设置',

										success(res) {
											if (res.confirm) {
												//打开授权设置
												that.openSetting();
											}
										}
									});
								}
							}
						});
					}
				});
			},

			goPoint() {
				uni.navigateTo({
					url: '../joinUS/joinUS'
				});
			}
		}
	};
</script>
<style>
	@import './index.css';
</style>
